char buff[8];
Semaphore emplybuffer(8);
Semaphore fullbuffer(0);
int main(){
	InitPackages(false);
	ThreadNew("writer",Writer,0);
	ThreadNew("Reader",Reader,0);
	RunAllThread();
}

void Writer(){
	for(int i=0;i<40;i++){
		SemaphoreWait(emplybuffer); // emply --
		char c = randomChar();
		SemaphoreSignal(fullbufer);// full ++
		buff[i%8] = c;
	}
}

void Reader(){
	for(int i=0;i<40;i++){
		SemaphoreWait(fullbuffer);//full--
		char c = buff[i%8];
		SemaphoreSignal(emplybuffer);// emply++
		process(c);
	}
}
